package leetcode;

/**
 * @author wangmaolin1
 * @date 2022/1/5 下午10:28
 */
public class _69Sqrt {

    public int mySqrt(int x) {
        int l = 0, r = x;
        int res=-1;
        while (l <= r) {
           int mid=l+(r-l)/2;
            if ((long)mid*mid<=x){
                res=mid;
                l=mid+1;
            }else {
                r=mid-1;
            }
        }
        return res;
    }

    public static void main(String[] args) {

    }

}
